/**
 * 风险评估字典条目规则表管理初始化
 */
var QcCaseDetail = {
	id: "ManageIndexCaseTable",	//表格id
	seItem: null,		//选中的条目
	table: null,
	layerIndex: -1,
	depType:"科室",
};
QcCaseDetail.drawTable = function(tableData){
    this.$table =
        $('#qcCaseDetailTable').bootstrapTable({
            data:tableData,

            striped: false,//是否显示行间隔色
            pagination: true,//是否显示分页
            showFooter: false,
            //paginationLoop: false,
            pageSize : 10,//用于设置每页初始显示的条数
            //pageList :[4],
            //sidePagination: 'server',//设置在哪进行分页，默认”client”，可选”server”,返回数据模板不同
            sortName: "evalDate",
            sortOrder: 'desc',// desc  asc
            maintainSelected: true,//设为true 为选中的状态
            cache: false,
            search:false, //搜索框
            columns: [
                {title: '患者姓名', field: 'name', align: 'center', width:50,valign: 'middle',sortable: false},
                {title: '病案号', field: 'mrNum', align: 'center', width:40,valign: 'middle',sortable: false},
                {title: '就诊科室', field: 'admLocDesc', align: 'center', width:50, valign: 'middle',sortable: false},
                {title: '主治医生', field: 'admDoctorName', align: 'center', width:80,valign: 'middle',sortable: false},
                {title: '入组病种', field: 'btDesc', align: 'center', width:100,valign: 'middle',sortable: false},
                {title: '入院日期', field: 'admDate', align: 'center', width:70, valign: 'middle',sortable: false},
                {title: '出院日期', field: 'dishDate', align: 'center', width:70, valign: 'middle',sortable: false},
                {title: '触发质控项', field: 'qcNum', align: 'center', width:70, valign: 'middle',sortable: false,
                    formatter:function(value,row,index){
                        if(row.qcNum >0){
                            return "<a title='详细' onclick='openQcDetail(&apos;"+row.id+"&apos;,&apos;"+row.name+"&apos;,&apos;"+row.mrNum+"&apos;)'>"+value+"</a>";
                        }else{
                            return 0;
                        }

                    }}
            ],
            onPostHeader: function(){  //当<thead></thead>中的内容被加载完后或者在你所用的DOM中有定义则被触发
                //$(".th-inner").css("font-weight","700");//表头字体加粗
                $("#qcCaseDetailTable > tbody td").each(function(index){//鼠标悬浮 显示表格数据
                    $(this).attr("title",$(this).text());
                });
            }
        });
};
/**
 * 初始化表格的列
 */
QcCaseDetail.initColumn = function () {
	return [
		{visible: false},
		{title: '患者姓名', field: 'name', align: 'left', width:60,valign: 'middle'},
		{title: '病案号', field: 'mrNum', align: 'left', width:80,valign: 'middle'},
		{title: '就诊科室', field: 'admLocDesc', align: 'left', width:100,valign: 'middle'},
		{title: '主治医生', field: 'admDoctorName', align: 'left', width:70, valign: 'middle'},
		{title: '入组病种', field: 'btDesc', align: 'left', width:70, valign: 'middle'},
		{title: '入院日期', field: 'admDate', align: 'left', width:60, valign: 'middle'},
		{title: '出院日期', field: 'dishDate', align: 'left', width:60, valign: 'middle'},
		{title: '触发质控项', field: 'qcNum', align: 'left', width:60, valign: 'middle'}
		// ,
		// {title: '确诊类别(类型)', field: 'confirmType', align: 'left', width:120,valign: 'middle',formatter:function(value,row,index){
		// 		var diagType = row.diagType;
		// 		var diagTypeDesc = "";
		// 		switch (diagType) {
		// 			case 0:	/*-*/
		// 				diagTypeDesc = ""
		// 				break;
		// 			case 1:	/*-*/
		// 				diagTypeDesc = "(PTE)"
		// 				break;
		// 			case 2:	/*-*/
		// 				diagTypeDesc = "(DVT)"
		// 				break;
		// 			case 3:	/*-*/
		// 				diagTypeDesc = "(其他血栓)"
		// 				break;
		// 			default:
		// 				break;
		// 		}
		// 		var type = "";
		// 		switch (value) {
		// 			case 0:	/*-*/
		// 				type = ""
		// 				break;
		// 			case 1:	/*-*/
		// 				type = "院外"+diagTypeDesc
		// 				break;
		// 			case 2:	/*-*/
		// 				type = "院内"+diagTypeDesc
		// 				break;
		// 			default:
		// 				break;
		// 		}
		// 		return type;
		// 	}},
		// {title: '确诊日期', field: 'confirmTime', align: 'center', width:180,valign: 'middle'}
	];
};


/**
 * 查询病例
 */
QcCaseDetail.search =function(){

    var ajax = new $ax(Sys.backendPath + "/analysis/qcportal/qcCaseList", function(data){
        $('#qcCaseDetailTable').bootstrapTable("destroy");//先销毁原来的表格
        QcCaseDetail.drawTable(data);
    },function(data){
        layer.msg("查询失败!" + data.responseJSON.message + "!",{icon: 2});
    });

    var params = {};
    params.date = $('#date').val();
    params.dateRange = $('#dateRange').val();
    params.startDate = $('#startDate').val();//开始日期
    params.endDate = $('#endDate').val();//开始日期
    params.office = $("#office").val();
    params.depart = $("#depart").val();
    params.medicalGroup = $("#medicalGroup").val();
    params.entityType = $("#entityType").val();
    params.doctor = $("#doctor").val();
    ajax.set(params);
    ajax.start();
}
function openQcDetail(episodeId,name,mrNum){
    var index = layer.open({
        type: 2,
        title: ['&nbsp;触发质控项-'+name+'-'+mrNum,'padding-left:20px'],
        area: ['900px', '397px'], //宽高
        fix: false, //不固定
        skin:'rbLBStyle  layer-ext-hisui',  //LB为layerBorder缩写
        //maxmin: true,
        content: Sys.backendPath + '/analysis/qcportal/to_qcDetail?episodeId='+episodeId
    });
}
$(function () {


	// var defaultColunms = AnalysisDocNurOpeDetail.initColumn();
	// var table = new BSTable(AnalysisDocNurOpeDetail.id, Sys.backendPath + "/analysisDocNur/opeList", defaultColunms);
	// table.setPaginationType("server");
	// table.setQueryParams({"opeId":opeId,"tableYear":tableYear,"startDate":startDate,"endDate":endDate,"riskFlag":riskFlag,"opeName":opeName,"role":role,"opeId":opeId,"depart":depart,"office":office})
	// table.setShowColumns(true);
	// table.setShowRefresh(true);
	// table.setPageSize(15);
	// table.setPageList([15,30,50,100]);
	// table.setShowToggle(true);
	// /*table.setFixedColumns(true);//是否固定列
	// table.setFixedNumber(4);//固定前几列*/
	// table.setSubHeight(-27);
    // AnalysisDocNurOpeDetail.table = table.init();
    QcCaseDetail.search();
});

